import React, { Component, PropTypes } from 'react';
import { InputItem, Button, WingBlank, WhiteSpace, List, Flex, NavBar, Icon, Toast, Popup, Menu } from 'antd-mobile';
import { Link } from 'react-router';
import { getLocalTime } from '../utils/func';

export default class CheckoutList extends Component {
	constructor(props){
		super(props);
		this.state = {
			curPage : 1
		}
	}

	getMore(){
		let { getMoreCheckoutList } = this.props;
		let nextPage = this.state.curPage + 1;
		this.setState({
			curPage : nextPage
		});
		getMoreCheckoutList(nextPage);
	}

	render() {
		let { checkoutList } = this.props;
		return (
				<div>
					<NavBar iconName='' mode="light" onLeftClick={(e) => {}}
					className='my_navbar_title'
				    >我的签退记录</NavBar>
				    <div className='my_container_blank'></div>
					<WhiteSpace size="sm" />

						<List>
							{
								checkoutList.length > 0 
								?
								checkoutList.map(function(item){
									return (
											<List.Item key={item.id}
												extra={getLocalTime(item.scan_time)}
											><Link to={{pathname:"checkout-detail/"+item.id}}>{item.building_name}/{item.classroom_name}：{item.student_count} 人</Link></List.Item>
										)
								})
								:
								<div className='no_record'>没有记录</div>
							}
					  	</List>
					  	<WhiteSpace size="sm" />
					    <Button onClick={(e) => {this.getMore();}}>更多...</Button>
				</div>
			);
	}
}